from django.shortcuts import render
from apps.website.models import Website
from apps.DispenProduct.models import DispenProduct
from apps.DispenProgram.models import DispenProgram
from apps.DispenAdvantage.models import DispenAdvantage,Dispentage,DispenPicture
# Create your views here.

def index(request):
    website = Website.objects.filter(is_delete=False, pk=1)
    dispen_program = DispenProgram.objects.filter(is_delete=False)
    dispen_product = DispenProduct.objects.filter(is_delete=False)

    if website:
        website = website[0]
        title = website.Title
        comp_address = website.comp_address
        comp_name = website.comp_name
        dispen_program = dispen_program
        dispen_product = dispen_product
    else:
        title = "请维护网站标题"
        comp_address="请维护公司地址"
        comp_name = "请维护公司名称"
        dispen_program = None
        dispen_product = None

    context = {
        'title': title,
        'address': comp_address,
        'comp_name': comp_name,
        'dispen_program': dispen_program,
        'dispen_product': dispen_product
    }


    return render(request,'index.html',context)

def detail(request):
    website = Website.objects.filter(is_delete=False, pk=1)
    dispen_advantage = DispenAdvantage.objects.filter(is_delete=False)

    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    if dispen_advantage:
        dispen_advantage_obj = dispen_advantage[0]
        dispen_advantage = dispen_advantage_obj.advantage
        dispen_detail = dispen_advantage_obj.detail
        dispen_title = dispen_advantage_obj.title
        dispen_tag = Dispentage.objects.filter(is_delete=False,advantage=dispen_advantage_obj.pk)
        dispen_picture = DispenPicture.objects.filter(is_delete=False,advantage=dispen_advantage_obj.pk)
    else:
        dispen_advantage = ""
        dispen_detail = ""
        dispen_title = ""
        dispen_tag = None
        dispen_picture = None

    context = {
        'title': title,
        'comp_name': comp_name,
        'dispen_advantage': dispen_advantage,
        'dispen_detail': dispen_detail,
        'dispen_title': dispen_title,
        'dispen_tag': dispen_tag,
        'dispen_picture': dispen_picture,
    }

    return render(request, 'detail.html', context)


#region 关于我们

def blog(request):
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'blog.html',context)


def future(request):
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'future.html',context)

def future(request):
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'future.html',context)

def Systems(request):
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'Systems.html',context)

def contact(request):
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'contact.html',context)

#endregion


#region 德豹之家
def gallery(request):
    # 德豹产品
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'gallery.html',context)

def leopard(request):
    # 德豹服务
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'leopard.html',context)

def voice(request):
    # 用户反馈
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'voice.html',context)

def faq(request):
    # 德豹印象
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'faq.html',context)

def DeBaoFans(request):
    # 德豹粉
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'DeBaoFans.html',context)

def group(request):
    # 德豹团
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'group.html',context)

#endregion


#region 十字之声
def doctors(request):
    # 招贤纳事
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'doctors.html',context)

def partnership(request):
    # 事业合伙
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'partnership.html',context)

def voiceOfCust(request):
    # 军歌嘹亮
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'voiceOfCust.html',context)

def impression(request):
    # 产业挚友
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'impression.html',context)

def crusaders(request):
    # 十字军
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'crusaders.html',context)

def lion(request):
    # 狮子会
    website = Website.objects.filter(is_delete=False, pk=1)
    if website:
        website = website[0]
        title = website.Title
        comp_name = website.comp_name
    else:
        title = "请维护网站标题",
        comp_name = "请维护公司名称",

    context = {
        'title': title,
        'comp_name': comp_name
    }

    return render(request,'lion.html',context)
#endregion


#region 摆药社区
#endregion